package algotithm.weekendrace.leetcode283.test1;

import java.util.ArrayList;
import java.util.List;

/**
 * @author tom
 * @date 2022-03-06 10:41
 */
class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        String s = "A1:F1";
        List<String> list = solution.cellsInRange(s);
        System.out.println(list);
    }

    public List<String> cellsInRange(String s) {
        List<String> res = new ArrayList<>();
        int n = s.length();
        String[] str = s.split(":");
        int r1 = str[0].charAt(1) - '0';
        int r2 = str[1].charAt(1) - '0';
        int c = (int)(str[1].charAt(0) - str[0].charAt(0) );
        char c2 = str[0].charAt(0);
        for (int j = 0; j <= c; j++) {
            char c1 = (char)(c2 + j);
            for (int i = 0; i <= r2 - r1 ; i++) {
                int num = r1 + i;
                String x = new String("" + c1 + num);
                res.add(x);
            }
        }

        return res;
    }
}